package com.example.demo.controller;

import io.swagger.annotations.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("user")
@Api(tags = "用户服务接口")
@RestController
public class UserController {

    @GetMapping("findAll")
    @ApiOperation(value = "查询所有用户信息")
    @ApiResponses({
            @ApiResponse(code = 404, message = "页面不存在")
    })
    public Map<String,Object> findAll(){
        HashMap<String, Object> map = new HashMap<>();
        map.put("success","查询成功");
        map.put("state",200);
        return map;
    }

    @PostMapping("save")
    @ApiOperation(value = "保存用户信息", notes = "保存用户信息接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "用户id",dataType = "String",defaultValue = "1.0"),
            @ApiImplicitParam(name = "name",value = "用户名",dataType = "String",defaultValue = "will ospreay")
    })
    @ApiResponses({
            @ApiResponse(code = 404, message = "页面不存在"),
            @ApiResponse(code = 500, message = "服务器出错"),
            @ApiResponse(code = 200,message = "响应成功")
    })
    public Map<String, Object> sve(String id, String name) {
        Map<String, Object> map = new HashMap<>();
        map.put("success", "保存用户信息");
        map.put("state", true);
        return map;
    }
}
